<?php

require_once __DIR__ . '/ControllerAbstract.php';
require_once '..' . DS . '/Models/ModelEntrada.php';
require_once '..' . DS . '/Models/ModelSaida.php';
require_once '..' . DS . '/Models/ModelData.php';

/**
 * Description of ControllerRelatorio
 *
 * @author david
 */
class ControllerRelatorio extends ControllerAbstract {

    protected $bancodedados = [];

    public function __construct($config) {
        parent::__construct($config);
    }

    public function principal() {
        $modelData = new ModelData();
        $data[] = $modelData->getMeses();
        $data[] = $modelData->getAnos();

        $this->render("relatorio/principal", $data);
    }

    public function imprimir() {
        $modelData = new ModelData();
        $data[] = $modelData->getMeses();
        $data[] = $modelData->getAnos();
        $data[] = "imprimir";

        $this->render("relatorio/principal", $data);
    }

    public function lista() {
        if (isset($_POST["mes"]) && isset($_POST["ano"])) {
            $mes = $_POST["mes"];
            $ano = $_POST["ano"];
        } else {
            $mes = date('m');
            $ano = date('Y');
        }

        $modelEntrada = new ModelEntrada();
        $modelSaida = new ModelSaida();
        $modelData = new ModelData();

        $entradas = $modelEntrada->getEntrada($mes, $ano);
        $saidas = $modelSaida->getSaida($mes, $ano);
        $saldo = $modelEntrada->getSaldo($mes, $ano);
        $mesTxt = $modelData->getMesCodigo($mes);

        $dados[] = $entradas;
        $dados[] = $saidas;
        $dados[] = $saldo;
        $dados[] = $ano;
        $dados[] = $mesTxt;

        $this->render("relatorio/lista", $dados);
    }

}
